﻿using System;
using System.Formats.Asn1;
using OpenCvSharp;

namespace FLANN
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var template = Cv2.ImRead("model/2.bmp");
            var target = Cv2.ImRead("test/2.bmp");
            // template = template.Resize(new Size(612, 512));
            // target = target.Resize(new Size(612, 512));
            // FLANN 匹配
            var matcher1 = new FLANNMatcher();
            matcher1.SetTemplate(template);
            matcher1.Execute(target);
            
            
            
            // 模板匹配
            // var matcher2 = new TemplateMatcher();
            // var matcher2 = new Template();
            // var answer= matcher2.CircleMatchNcc(target, template, 0,
            //     360, 5, 3, 0.5, 5);
            // var answer = matcher2.RotatingTemplateMatching(target, template, 360, 20, 0, 3, 0.5, 5);
            // Console.Write("{0:D} {1:D} {2:F} {3:F}",answer.Item1,answer.Item2,answer.Item3,answer.Item4);
            // Console.Write("{0:F} {1:F} {2:F} {3:F}",answer.Score,answer.T,answer.X,answer.Y);
            // var rect = new Rect(answer.X, answer.Y, template.Width, template.Height);
            // target.Rectangle(rect,Scalar.Red);
            // Point center = new Point(answer.X + template.Width / 2, answer.Y + template.Height / 2);
            // Cv2.Circle(target,new Point(answer.X,answer.Y),2,Scalar.Red,3);
            // Cv2.Circle(target,center,2,Scalar.Red,3);
             
            Cv2.Resize(target,target,new Size(1224,1024));
            Cv2.ImShow("Target",target);
            
            Cv2.WaitKey(0);
            
            
            // 轮廓检测
            // var matcher3 = new ContourMatcher(0.3,0.2,
            //     1000,0,40);
            // matcher3.Matching(target, template);
            //todo 均质化后前后景突出但是噪点增加难以获得轮廓
        }
    }
}
